using GroupSix.Domain.Entity.App;
using GroupSix.Domain.common;

namespace GroupSix.Domain.Repositories;

/// <summary>
/// 菜单仓库接口
/// </summary>
public interface IMenuRepository : IRepository<GsMenu>
{
    /// <summary>
    /// 检查菜单名称是否存在
    /// </summary>
    /// <param name="menuname">菜单名称</param>
    /// <param name="excludeId">排除的菜单ID</param>
    /// <returns>是否存在</returns>
    Task<bool> IsMenunameExistsAsync(string menuname, Guid? excludeId = null);

    /// <summary>
    /// 检查菜单路径是否存在
    /// </summary>
    /// <param name="menuPath">菜单路径</param>
    /// <param name="excludeId">排除的菜单ID</param>
    /// <returns>是否存在</returns>
    Task<bool> IsMenuPathExistsAsync(string menuPath, Guid? excludeId = null);

    /// <summary>
    /// 根据名称获取菜单
    /// </summary>
    /// <param name="menuname">菜单名称</param>
    /// <returns>菜单</returns>
    Task<GsMenu?> GetByMenunameAsync(string menuname);

    /// <summary>
    /// 根据路径获取菜单
    /// </summary>
    /// <param name="menuPath">菜单路径</param>
    /// <returns>菜单</returns>
    Task<GsMenu?> GetByMenuPathAsync(string menuPath);

    /// <summary>
    /// 分页获取菜单列表
    /// </summary>
    /// <param name="pageIndex">页码</param>
    /// <param name="pageSize">页大小</param>
    /// <param name="menuname">菜单名称搜索</param>
    /// <param name="menuPath">菜单路径搜索</param>
    /// <param name="parentId">父菜单ID筛选</param>
    /// <returns>分页结果</returns>
    Task<PageResult<GsMenu>> GetPagedAsync(int pageIndex, int pageSize, string? menuname = null, string? menuPath = null, Guid? parentId = null);

    /// <summary>
    /// 获取菜单树
    /// </summary>
    /// <returns>菜单树</returns>
    Task<List<GsMenu>> GetMenuTreeAsync();

    /// <summary>
    /// 获取指定父菜单的子菜单
    /// </summary>
    /// <param name="parentId">父菜单ID</param>
    /// <returns>子菜单列表</returns>
    Task<List<GsMenu>> GetChildrenAsync(Guid? parentId);

    /// <summary>
    /// 检查菜单是否有子菜单
    /// </summary>
    /// <param name="menuId">菜单ID</param>
    /// <returns>是否有子菜单</returns>
    Task<bool> HasChildrenAsync(Guid menuId);

    /// <summary>
    /// 检查菜单是否被角色使用
    /// </summary>
    /// <param name="menuId">菜单ID</param>
    /// <returns>是否被使用</returns>
    Task<bool> IsUsedByRolesAsync(Guid menuId);

    /// <summary>
    /// 获取菜单的角色数量
    /// </summary>
    /// <param name="menuId">菜单ID</param>
    /// <returns>角色数量</returns>
    Task<int> GetRoleCountAsync(Guid menuId);

    /// <summary>
    /// 更新菜单排序
    /// </summary>
    /// <param name="menuId">菜单ID</param>
    /// <param name="order">新排序值</param>
    /// <returns>是否成功</returns>
    Task<bool> UpdateOrderAsync(Guid menuId, int order);

    /// <summary>
    /// 获取同级菜单的最大排序值
    /// </summary>
    /// <param name="parentId">父菜单ID</param>
    /// <returns>最大排序值</returns>
    Task<int> GetMaxOrderAsync(Guid? parentId);
} 